package com.yzc.service;

import com.yzc.Dto.roleMenu;
import com.yzc.pojo.RoleBean;
import com.yzc.service.impl.RoleDao;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@RequiredArgsConstructor
public class RoleService {
    final RoleDao roleDao;

    public List<RoleBean> loadRoleList() {
        return roleDao.loadRoleList();
    }

    public Map updateInfo(RoleBean roleBean) {
        return roleDao.updateInfo(roleBean);
    }

    public Map save(RoleBean roleBean) {
        return roleDao.save(roleBean);
    }


    public List<roleMenu>  loadRoleMenus(RoleBean roleBean) {
        return roleDao.loadRoleMenus(roleBean);
    }

    public Map deleteInfo(RoleBean roleBean) {
        return roleDao.deleteInfo(roleBean);
    }

    public Map saveAuthorizationRoleMenu(RoleBean roleBean) {
        Map map = new HashMap();
        try {
            roleDao.saveAuthorizationRoleMenu(roleBean);
            map.put("result", "success");
        }
        catch (Exception e) {
            map.put("result", "error");
            throw new RuntimeException(e);
        }
        return map;
    }
}
